package com.cweb.admin.model.sys.sys_config.controller;

import com.cweb.admin.configuration.annotation.NoLoginCheck;
import com.cweb.admin.model.sys.sys_config.entity.SysConfig;
import com.cweb.admin.model.sys.sys_config.service.SysConfigService;
import com.cweb.framework.annotation.Remark;
import com.cweb.framework.base.controller.BaseController;
import com.cweb.framework.pojo.BaseResponse;
import com.cweb.framework.pojo.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 系统-配置信息
 * </p>
 *
 * @author changfan
 * @since 2019-04-23
 */
@Controller
@RequestMapping("sysConfig")
public class SysConfigController extends BaseController {
    @Autowired
    private SysConfigService sysConfigService;

    @ResponseBody
    @RequestMapping("getConfig")
    @Remark(name = "刷新配置文件缓存", describe = "")
    @NoLoginCheck
    public BaseResponse getConfig() throws CustomException {
        return new BaseResponse(sysConfigService.getConfig());
    }

    @ResponseBody
    @RequestMapping("delConfig")
    @Remark(name = "刷新配置文件缓存", describe = "")
    @NoLoginCheck
    public BaseResponse delConfig() throws CustomException {
        sysConfigService.delConfig();
        return new BaseResponse();
    }

    @ResponseBody
    @RequestMapping("select")
    @Remark(name = "查询", describe = "")
    public BaseResponse select(SysConfig param) throws CustomException {
        return new BaseResponse(sysConfigService.processSelect(param));
    }

    @ResponseBody
    @RequestMapping("add")
    @Remark(name = "新增", describe = "")
    public BaseResponse add(SysConfig param) throws CustomException {
        return new BaseResponse(sysConfigService.processAdd(param));
    }

    @ResponseBody
    @RequestMapping("change")
    @Remark(name = "更新", describe = "")
    public BaseResponse update(SysConfig param) throws CustomException {
        return new BaseResponse(sysConfigService.processChange(param));
    }

    @ResponseBody
    @RequestMapping("delete")
    @Remark(name = "删除", describe = "")
    public BaseResponse delete(SysConfig param) throws CustomException {
        return new BaseResponse(sysConfigService.processDelete(param));
    }
}

